# Contributor: Mohammad Abdolirad <m.abdolirad@gmail.com>
# Maintainer: Mohammad Abdolirad <m.abdolirad@gmail.com>
pkgname=wait4x
pkgver=2.13.0
pkgrel=6
pkgdesc="Wait4X allows you to wait for a port or a service to enter the requested state"
url="https://wait4x.dev"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
"
source="$pkgname-$pkgver.tar.gz::https://github.com/atkrad/wait4x/archive/v$pkgver.tar.gz"
options="!check" # Wait4X doesn't provide tests

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	WAIT4X_COMMIT_REF_SLUG="v$pkgver" make build

	./dist/$pkgname completion bash > $pkgname.bash
	./dist/$pkgname completion fish > $pkgname.fish
	./dist/$pkgname completion zsh > $pkgname.zsh
}

package() {
	install -Dm755 "$builddir"/dist/$pkgname "$pkgdir"/usr/bin/$pkgname
	install -Dm644 "$builddir"/LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -Dm644 $pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
a421a4845ca2146b172697aa22a43cbec129f143e4c971e4d621448cc0be6d872a7d551d1cbe5d82c83d65ef87de701907b8623e33f508798d3e0ff31e24cc17  wait4x-2.13.0.tar.gz
"
